/****************************************************************************
*                                                                           *
* sensorgraph.cpp															*	
*                                                                           *
* ALaRI 2008												                *
*                                                                           *
****************************************************************************/
#include "sensorgraph.h"
#include <QListIterator>

CSensorGraph::CSensorGraph(QList<CSensor*> qListSensors)
{
	QListIterator<CSensor*> qListItNodeFrom(qListSensors); 
	QList<CSensor*>::iterator qListItNodeTo; 
	
	while (qListItNodeFrom.hasNext())
	{
		CSensor *pNodeFrom = qListItNodeFrom.next();
		assert(NULL != pNodeFrom);
		assert(pNodeFrom->isFieldUpdated()); 
		if (false == pNodeFrom->isFieldUpdated())
			// TODO : throw an exception here 
			return; 
		addNode(pNodeFrom);
	}
	qListItNodeFrom = qListSensors;

	while (qListItNodeFrom.hasNext())
	{
		CSensor *pNodeFrom = qListItNodeFrom.next();
		if (NULL != pNodeFrom)
		{	
			qListItNodeTo = qListSensors.begin();
			while (qListItNodeTo != qListSensors.end())
			{
				CSensor *pNodeTo = *qListItNodeTo;
				makeEdge(pNodeFrom, pNodeTo, pNodeFrom->getFieldAt(pNodeTo->x(), pNodeTo->y()));
				*qListItNodeTo++;
			}
		}
	}
}

CSensorGraph::~CSensorGraph()
{
}